package com.wangsd.member.service;

import com.gitee.fastmybatis.core.query.Query;
import com.gitee.fastmybatis.core.query.Sort;
import com.wangsd.member.entity.GoldRecord;
import com.wangsd.member.mapper.GoldRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 金币流水记录Service业务层处理
 *
 * @author wsd
 * @date 2021-06-28
 */
@Service
public class GoldRecordService {
    @Autowired
    private GoldRecordMapper goldRecordMapper;

    /**
     * 查询金币流水记录
     *
     * @param id 金币流水记录ID
     * @return 金币流水记录
     */
    public GoldRecord selectGoldRecordById(Long id) {
        return goldRecordMapper.getById(id);
    }

    /**
     * 查询金币流水记录列表
     *
     * @param goldRecord 金币流水记录
     * @return 金币流水记录
     */
    public List<GoldRecord> selectGoldRecordList(GoldRecord goldRecord) {
        Query query = new Query();
        query.orderby("id", Sort.DESC);
        List<GoldRecord> list = goldRecordMapper.list(query);
        return list;
    }

    /**
     * 新增金币流水记录
     *
     * @param goldRecord 金币流水记录
     * @return 结果
     */
    public int insertGoldRecord(GoldRecord goldRecord) {
        return goldRecordMapper.saveIgnoreNull(goldRecord);
    }

    /**
     * 修改金币流水记录
     *
     * @param goldRecord 金币流水记录
     * @return 结果
     */
    public int updateGoldRecord(GoldRecord goldRecord) {
        return goldRecordMapper.updateIgnoreNull(goldRecord);
    }

    /**
     * 删除金币流水记录信息
     *
     * @param id 金币流水记录ID
     * @return 结果
     */
    public int deleteGoldRecordById(Long id) {
        return goldRecordMapper.deleteById(id);
    }
}
